package com.hnas.trade.domain;

import java.util.HashMap;
import java.util.Map;

public enum OrderStatus {

	Unpay("0", "未付款"), Payed("1", "付款成功"), PayFail("2", "付款失败"), Paying("3",
			"付款中"), FailCreate("4", "创建订单失败"), OVERTIME("5", "支付超时"), ABNORMAL(
			"6", "支付异常"), Account("7", "记账");
	private String status;
	private String description;

	private OrderStatus(String status, String description) {
		this.status = status;
		this.description = description;
	}

	public String getStatus() {
		return status;
	}

	public void setStatus(String status) {
		this.status = status;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public static OrderStatus getStatus(String key) {
		for (OrderStatus status : OrderStatus.values()) {
			if (status.getStatus().equals(key)) {
				return status;
			}
		}
		return null;
	}
	
	public static Map<String, String> getOrderStatusMap(){
		Map<String, String> map = new HashMap<String, String>();
		for (OrderStatus status : OrderStatus.values()) {
			map.put(status.getStatus(), status.getDescription());
		}
		return map;
	}

	public static String getOrderStatusString(String key) {
		return getStatus(key) == null ? "" : getStatus(key)
				.getDescription();
	}

}
